#include <vector>
#include <cilk/reducer_list.h>
#include "Vec.h"
#include "Line.h"

using namespace std;

//Represents a rectangle of the 
//quadtree. 
struct Rect
{
  Vec sw;
  Vec nw;
  Vec se;
  Vec ne;

  //Lines that intersect the 
  //rectangle.
  vector<Line*> lines;
};     

class Quadtree
{
protected:
  vector<Rect*> rects;
  cilk::reducer_list_append<Rect*> cilk_rects;
  unsigned int maxElements;
  void getInitRect(vector<Line*>& lines, Rect * rect);
  void divideRect(Rect* parent, int depth);

public:
  Quadtree(vector<Line*>& lines, unsigned int n);
  ~Quadtree();
  vector<Rect*>& getRects();
};
